package com.huanghoulin.java.io;

import static org.junit.Assert.*;

import java.io.File;

import org.junit.Test;
public class FileDemo {
	
	@Test
	public void file() throws Exception {
		
		//1：绝对路径的方式
		File f01 = new File("D:/io/helloWorldIO.txt");
		System.out.println("        getName:\t"+f01.getName());
		System.out.println("        getPath:\t"+f01.getPath());
		//获取文件的名字  带路径的
		System.out.println("getAbsoluteFile:\t"+f01.getAbsoluteFile());
		System.out.println("getAbsolutePath:\t"+f01.getAbsolutePath());
		System.out.println("      getParent:\t"+f01.getParent());
		
		System.out.println("===============================================");
		//2:相对路径的方式
		File f02 = new File("io/helloWorld.txt");
		System.err.println("        getName:\t"+f02.getName());
		System.err.println("        getPath:\t"+f02.getPath());
		//获取文件的名字  带路径的
		System.err.println("getAbsoluteFile:\t"+f02.getAbsoluteFile());
		System.err.println("getAbsolutePath:\t"+f02.getAbsolutePath());
		System.err.println("      getParent:\t"+f02.getParent());
		
	}
	
	@Test
	public void directory() throws Exception {
		File directory = new File("D:/io/directory88");
		System.out.println("        getName:\t"+directory.getName());
		System.out.println("        getPath:\t"+directory.getPath());
		System.out.println("getAbsolutePath:\t"+directory.getAbsolutePath());
		System.out.println("getAbsoluteFile:\t"+directory.getAbsoluteFile());
		System.out.println("      getParent:\t"+directory.getParent());
		
	}

}
